package com.hzlj.position.config.common.enums;

import com.fz.common.base.exception.PubError;
import com.fz.common.base.exception.PubException;
import lombok.Getter;

/**
 * @author lifh
 * @date 2021/11/9 上午11:59
 **/
@Getter
public enum CRUDEnum {
    /**
     * 类型  0：增 1：删 2：改 3：查
     */
    ADD("0", "新增"),
    DEL("1", "删除"),
    UPDATE("2", "修改"),
    UPDATE_DEVICE_CODE("3", "修改"),
    ;

    private String code;
    private String codeText;

    CRUDEnum(String code, String codeText) {
        this.code = code;
        this.codeText = codeText;
    }

    public static CRUDEnum of(String code) {
        for (CRUDEnum statusEnum : values()) {
            if (statusEnum.code.equalsIgnoreCase(code)) {
                return statusEnum;
            }
        }
        throw new PubException(PubError.PARAM_EMPTY_ERROR);
    }
}
